package hash;

import java.util.HashMap;
import java.util.HashSet;

public class UniqueOccurrences {
    public static boolean uniqueOccurrences(int[] arr) {
        HashMap<Integer,Integer> map1 = new HashMap<>();
        for(int num : arr){
            if(!map1.containsKey(num)){
                map1.put(num,1);
            }else{
                map1.put(num,map1.get(num) + 1);
            }
        }
        HashSet<Integer> set = new HashSet();
        for(int value : map1.values()){
            if(set.contains(value)){
                return false;
            }else{
                set.add(value);
            }
        }
        return true;
    }
    public static void main(String[] args) {
        int[] arr = {1, 2, 2, 3, 3, 3};
        boolean result = uniqueOccurrences(arr);
        System.out.println(result); // 应该返回 true
    }
}
